package com.example.clublesson01.adapter

import android.widget.ImageView
import com.bumptech.glide.Glide
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
import com.bw.kf.lib_base.entity.PlayCartInfoImage
import com.bw.kf.lib_base.entity.TieDetailImage
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.example.clublesson01.R

class PlayCartInfoChildAdapter(private val ImgSize: Int) :
    BaseQuickAdapter<PlayCartInfoImage, BaseViewHolder>(R.layout.play_cart_info_child_item) {
    override fun convert(helper: BaseViewHolder, item: PlayCartInfoImage) {
        val play_cart_info_child_img = helper.getView<ImageView>(R.id.play_cart_info_child_img)
        if (ImgSize == 1) {
            val layoutParams = play_cart_info_child_img.layoutParams

            if (item.imageHeight > 1920) {
                layoutParams.height = 800
            } else {
                layoutParams.height = item.imageHeight
            }

            if (item.imageWidth > 1080) {
                layoutParams.width = 800
            } else {
                layoutParams.width = item.imageWidth
            }
            play_cart_info_child_img.layoutParams = layoutParams
        }
        Glide.with(this.context).load(item.url).transform(
            RoundedCorners(10)
        ).into(play_cart_info_child_img)


    }
}



class TieDetailImgAdapter: BaseQuickAdapter<TieDetailImage, BaseViewHolder>(R.layout.item_tie_img) {
    override fun convert(holder: BaseViewHolder, item: TieDetailImage) {
        val imageView = holder.getView<ImageView>(R.id.play_cart_info_child_img)
        Glide.with(this.context).load(item.url).transform(RoundedCorners(10))
            .into(imageView)
    }
}